<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	String xm = this.getServletContext().getInitParameter("path");
	String path1 = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/"
			+ xm;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>添加项目</title>

<base target="_self" />
<link href="<%=path1%>/ht/Styles/css.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path1%>/ht/Styles/ts_css.css" rel="stylesheet"
	type="text/css" />
<script type="text/javascript"
	src="<%=path1%>/scripts/My97DatePicker/WdatePicker.js"></script>
<script src="<%=path1%>/ht/Scripts/jquery-1.4.1.min.js"
	type="text/javascript"></script>
<script src="<%=path1%>/ht/Scripts/IndexManager.js"
	type="text/javascript"></script>
<script type="text/javascript">
    
    function addAjax(){
    	$.ajax({
    		data:{
    			project_id:$("#project_id").val(),
    			project_name:$("#project_name").val(),
    			start_time:$("#start_time").val(),
    			end_time:$("#end_time").val(),
    			create_user_id:$("#create_user_id").val(),
    		    product_type:$("#product_type").val(), 
    		    create_time:$("#create_time").val,
    			/* product_type : $("input=[name='product_type'] option:selected").val(), */
    			state:$("#state").val(), 
    			/* state : $("input=[name='state'] option:selected").val(), */
    			remark:$("#remark").val()
    		},
    		type:"post",
    		datatype:'json',
    		url:"<%=path1%>/qt/ht/project/addProject.do",
    		error:function(data){
    			alert("出错了");
    		},
            success:function(data){
            	window.location.href="<%=path1%>/qt/ht/project/selectAll.do";
            }
    	});
    	
    }
    
  //项目名称查询
	$.ajax({
				url : "<%=path1%>/qt/ht/project/selectAlls.do",
				datatype : 'json',
				error : function(data) {
					alert("出错了！！");
				},
				success : function(data) {
					var len = data.msg.length;
					var html = "";
					if (len > 0) {
						data.msg.forEach(function(e) {
									if (e.project_id == project_id) {
										alert(e.project_name);
										html += "<option value="+e.project_id+" selected='selected'>"
												+ e.project_name + "</option>";
									} else {
										html += "<option value="+e.project_id+">"
												+ e.project_name + "</option>";
									}
								})
						//alert(html);
						$("#project_id").append(html);
					}
				}
			});
    </script>
<script type="text/javascript">
  function breaks(){
	  window.location.href="<%=path1%>/qt/ht/project/selectAll.do";
	}
</script>

<script>
	function danji1() {
		var name = document.getElementById("product_type").value;
	}
	function danji2() {
		var name = document.getElementById("state").value;
	}
</script>
</head>
<body>

	<form id="form1" method="post">
		<div id="divTwo">
			<table width="100%" border="0" cellpadding="3" cellspacing="3"
				class="table_list1">
				<h2 align="center">添加项目信息</h2>
				<tr>
					<td width="45%" class="table_list1_style1">
						<p></p> <span style="color: Red">*</span> 项目名称:
					</td>
					<td width="55%" class="table_list1_style2">
<%-- 					<c:choose>
						<c:when test="${bean.tel=='admin'}">
							<select  style="width: 140px; height: 25px">
							    <c:forEach items="${projects}" var="b">
									<option value="${b.project_name}">${b.project_name}</option>
								</c:forEach>
							</select>
						</c:when>
						<c:forEach items="${projects}" var="b">
						<c:when test="${bean.tel==b.tel}">
						     <select style="width: 140px; height: 25px">
						         <c:forEach items="${projects}" var="a">						        
									<option value="${a.project_name}">${a.project_name}</option>
								 </c:forEach> 
						     </select> 
						</c:when>
						 </c:forEach> 
					</c:choose> 
					
                    <select type="text" id="project_name" name="project_name" style="width: 140px;">
					   <c:forEach items="${projectpross}" var="a">
					     <option value="${a.project_name}">${a.project_name}</option>
					   </c:forEach>
					</select>--%>
					<input type="text"
						id="project_name" name="project_name" />
					</td>
				</tr>

				<tr>
					<td width="10%" class="table_list1_style1">
						<p></p> <span style="color: Red">*</span> 产品类型:
					</td>
					<td width="10%" class="table_list1_style2"><select type="text"
						id="product_type" name="product_type" style="width: 140px;">
							<option value="住宅">住宅</option>
							<option value="商业">商业</option>
							<option value="产房">产房</option>
							<option value="配套">配套</option>
							<option value="公共建筑">公共建筑</option>
					</select></td>
				</tr>

				<tr>
					<td width="10%" class="table_list1_style1">
						<p></p> <span style="color: Red">*</span> 开始时间:
					</td>
					<td width="10%" class="table_list1_style2"><input type="text"
						id="start_time" class="Wdate" onclick="WdatePicker();" /></td>
				</tr>

				<tr>
					<td width="10%" class="table_list1_style1">
						<p></p> <span style="color: Red">*</span> 结束时间:
					</td>
					<td width="10%" class="table_list1_style2"><input type="text"
						id="end_time" class="Wdate" onclick="WdatePicker();" /></td>
				</tr>
			<c:choose>
              <c:when test="${bean.tel=='admin'}">
				<tr>
					<td width="10%" class="table_list1_style1">
					 	 <p></p> <span style="color: Red">*</span> 负责人: 
					</td>
					<td width="10%"c class="table_list1_style2">
					<select type="text" name="create_user_id" id="create_user_id" style="width: 140px;">
					<c:forEach items="${projectList}" var="a">
					<option value="${a.tel}">${a.tel}</option>
					</c:forEach>
					</select>
					</td>
				</tr>
               </c:when>
               <c:otherwise>
				<tr>
					<!-- <td width="10%" class="table_list1_style1">
						<p></p> <span style="color: Red">*</span> 负责人编号:
					</td> -->
					 
					<!-- <td width="10%" class="table_list1_style2"> --><input type="hidden"
						id="create_user_id" name="create_user_id" />
					<!-- </td> -->
				
				</tr>
               </c:otherwise> 
              </c:choose>
				<tr>
					<td width="10%" class="table_list1_style1">
						<p></p> <span style="color: Red">*</span> 状态:
					</td>
					<td width="10%" class="table_list1_style2"><select type="text"
						id="state" name="state" style="width: 140px;">
							<option value="待建">待建</option>
							<option value="在建">在建</option>
							<option value="完成">完成</option>
					</select></td>
				</tr>

				<tr>
					<td width="10%" class="table_list1_style1"><p></p> 备注:</td>
					<td width="10%" class="table_list1_style2"><input type="text"
						id="remark" name="remark" /></td>
				</tr>

				<tr>
					<td class="table_list1_style1">

						<p></p> <input type="button" id="send" value="添加" tabindex="1"
						class="button" onclick="addAjax();addopeningrooms();" /> &nbsp;
					</td>
					<td width="1%" class="table_list1_style2">

						<p></p> <input type="button" class="button" value="返回"
						tabindex="1" onclick="breaks();" />
					</td>
					<td class="table_list1_style1">&nbsp;</td>
				</tr>

			</table>
		</div>
	</form>
</body>
</html>